﻿using EEM.Helpers;
using EEM.LocalModels;
using EEM.Models;
using HZH_Controls.Controls;
using Microsoft.VisualBasic;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics.Metrics;
using System.Drawing;
using System.Linq;
using System.Security.Cryptography.Xml;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace EEM.Pages
{
    public partial class PgForm : Form
    {
        public PgForm()
        {
            InitializeComponent();
        }

        private void PgForm_Load(object sender, EventArgs e)
        {
            //管道控件的流动加载
            flowLoad(true);

            btnStart.BtnText = "停止";
            btnStart.FillColor = Color.OrangeRed;
            btnStart.RectColor = Color.OrangeRed;
        }


        private void flowLoad(bool isFlow)
        {
            int speed = isFlow ? 100 : 10000000;
            foreach (var c in this.panel.Controls)
            {
                if (c is UCConduit)
                {
                    ((UCConduit)c).LiquidSpeed = speed;
                }
            }
        }

        /// <summary>
        /// 启动与停止按钮
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnStart_BtnClick(object sender, EventArgs e)
        {
            if (!CommonHelper.isStarted)
            {
                if (CommonHelper.isSettingUpdates)
                {
                    //重新加载从站列表
                    //重新加载区域配置
                    //重新加载参数列表
                    CommonHelper.LoadConfigInfo();
                    CommonHelper.isSettingUpdates = false;
                }
                CommonHelper.timer.Start();
                CommonHelper.isStarted = true;
                btnStart.BtnText = "停止";
                btnStart.FillColor = Color.OrangeRed;
                btnStart.RectColor = Color.OrangeRed;
            }
            else
            {
                CommonHelper.timer.Stop();
                CommonHelper.isStarted = false;
                btnStart.BtnText = "启动";
                btnStart.FillColor = Color.DodgerBlue;
                btnStart.RectColor = Color.DodgerBlue;
            }
        }



        private void button1_Click(object sender, EventArgs e)
        {
            foreach (int i in CommonHelper.dicDatas.Keys)
            {
                MessageBox.Show(CommonHelper.dicDatas[i].Humidity.ToString());
            }
        }

    }
}
